package com.example.websocket.handler;

import com.example.websocket.enums.SupportType;
import org.springframework.core.Ordered;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.WebSocketMessage;
import org.springframework.web.socket.WebSocketSession;

public interface OrderdWebSocketHandler extends WebSocketHandler, Ordered  {

    boolean support(SupportType supportType, WebSocketSession session, Object message);

    String getType();


    default void afterConnectionEstablished(WebSocketSession session) throws Exception {

    }

    default void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception{

    }

    default void handleTransportError(WebSocketSession session, Throwable exception) throws Exception{

    }

    default void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception{

    };


    default  boolean supportsPartialMessages(){
        return false;
    }
}
